Imports Microsoft.VisualBasic

Namespace MyReport
    <ParseChildren(True)> _
    Public Class Search2View
        Inherits Control
        Implements INamingContainer

        'Protected Overrides Sub CreateChildControls()
        '    Dim container As New Control

        '    Select Case Me.ReportMode
        '        Case Global.ReportModeE.Normal
        '            NormalSearchTemplate.InstantiateIn(container)
        '        Case Global.ReportModeE.Meeting
        '            MeetingSearchTemplate.InstantiateIn(container)
        '    End Select

        '    Me.Controls.Add(container)
        'End Sub

        Protected Overrides Sub OnInit(ByVal e As System.EventArgs)
            MyBase.OnInit(e)

            Me.BindControl()
        End Sub

        Public Sub BindControl()
            Dim container As New Control

            Select Case Me.ReportMode
                Case Global.ReportModeE.Normal
                    NormalSearchTemplate.InstantiateIn(container)
                Case Global.ReportModeE.Meeting
                    MeetingSearchTemplate.InstantiateIn(container)
                Case Global.ReportModeE.Gross
                    GrossSearchTemplate.InstantiateIn(container)
                Case Global.ReportModeE.Act
                    ActSearchTemplate.InstantiateIn(container)
                Case Global.ReportModeE.TCPop
                    TCPopTemplate.InstantiateIn(container)
            End Select

            Me.Controls.Clear()
            Me.Controls.Add(container)
        End Sub

        Public Property ReportMode() As ReportModeE
            Get
                If ViewState("ReportMode") Is Nothing Then
                    Return ReportModeE.Normal
                End If

                Return ViewState("ReportMode")
            End Get
            Set(ByVal value As ReportModeE)
                ViewState("ReportMode") = value
            End Set
        End Property

        Protected _NormalSearchTemplate As ITemplate

        <PersistenceMode(PersistenceMode.InnerProperty)> _
        Public Property NormalSearchTemplate() As ITemplate
            Get
                Return Me._NormalSearchTemplate
            End Get
            Set(ByVal value As ITemplate)
                Me._NormalSearchTemplate = value
            End Set
        End Property

        Protected _TCPopTemplate As ITemplate

        <PersistenceMode(PersistenceMode.InnerProperty)> _
        Public Property TCPopTemplate() As ITemplate
            Get
                Return Me._TCPopTemplate
            End Get
            Set(ByVal value As ITemplate)
                Me._TCPopTemplate = value
            End Set
        End Property

        Protected _MeetingSearchTemplate As ITemplate

        <PersistenceMode(PersistenceMode.InnerProperty)> _
        Public Property MeetingSearchTemplate() As ITemplate
            Get
                Return Me._MeetingSearchTemplate
            End Get
            Set(ByVal value As ITemplate)
                Me._MeetingSearchTemplate = value
            End Set
        End Property

        Protected _GrossSearchTemplate As ITemplate

        <PersistenceMode(PersistenceMode.InnerProperty)> _
        Public Property GrossSearchTemplate() As ITemplate
            Get
                Return Me._GrossSearchTemplate
            End Get
            Set(ByVal value As ITemplate)
                Me._GrossSearchTemplate = value
            End Set
        End Property


        Protected _ActSearchTemplate As ITemplate

        <PersistenceMode(PersistenceMode.InnerProperty)> _
        Public Property ActSearchTemplate() As ITemplate
            Get
                Return Me._ActSearchTemplate
            End Get
            Set(ByVal value As ITemplate)
                Me._ActSearchTemplate = value
            End Set
        End Property


        Protected _FcstSearchTemplate As ITemplate

        <PersistenceMode(PersistenceMode.InnerProperty)> _
        Public Property FcstSearchTemplate() As ITemplate
            Get
                Return Me._FcstSearchTemplate
            End Get
            Set(ByVal value As ITemplate)
                Me._FcstSearchTemplate = value
            End Set
        End Property
    End Class
End Namespace
